const Koa = require('koa')
// const { APP_HOST, APP_PORT } = require('./config')
const bodyParser = require('koa-bodyparser')
const errorHandler = require('./error-handle')
const useRoutes = require('../router')
const { verifyToken } = require('../middleware/auth.mid')
// const json = require('koa-jsonp')
const cors = require('koa-cors')

const app = new Koa()

app.use(
  cors({
    methods: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT'],
  })
)
app.use(bodyParser())
app.use(verifyToken)
useRoutes(app)
app.on('error', errorHandler)

module.exports = app
